/* GUI CONVERTED from recimrp.p (converter v1.75) Sat Aug 12 23:05:04 2000 */
/* recimrp.p - REPETITIVE CIM FILE CREATE FOR CUMULATIVE ORDER MAINTENANCE    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* web convert recimrp.p (converter v1.00) Fri Oct 10 13:57:57 1997 */
/* web tag in recimrp.p (converter v1.00) Mon Oct 06 14:18:36 1997 */
/*K1GZ*/ /*                                                    */
/*V8:ConvertMode=Report                                                       */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                       */
/* REVISION: 7.3      LAST MODIFIED: 01/16/96           BY: flm *G1JB*        */
/* REVISION: 8.6      LAST MODIFIED: 02/12/98  BY: *K1GZ* Beena Mol          */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/*                                                                            */
/* THIS PROGRAM CREATES AN OUTPUT FILE TO CREATE CUMULATIVE ORDERS USING      */
/* CUMULATIVE ORDER MAINTENANCE (recwomt.p)                                   */
/* THE FOLLOWING IS A SAMPLE OF THE OUTPUT CREATED BY THIS PROGRAM *
.
.      @@batchload recwomt1.p
.      ""
.      "site"   "part"            "production line"
.      "routing"                  "bom code"                  MM/DD/YY
.      "yes"
.      .
.      .
.      @@end
.
/* END OF SAMPLE OUTPUT FOR CIM FILE */                                       */
/*                                                                            */
/* THIS PROGRAM CAN BE CUSTOMIZED TO PROMPT THE USER FOR END EFFECTIVE DATE   */
/* AND USE IT TO UPDATE THE DEFAULT END EFFECTIVE DATE THAT IS SET BY THE     */
/* PARAMETERS IN THE REPETITIVE CONTROL FILE (rerepm.p)                       */
/* THE FOLLOWING IS A SAMPLE OF WHAT THE OUTPUT SHOULD LIKE TO UPDATE THE     */
/* DEFAULT START AND END EFFECTIVE DATES *
.
.      @@batchload recwomt1.p
.      ""
.      "site"   "part"            "production line"
.      "routing"                  "bom code"                  MM/DD/YY
.      "yes"
.      MM/DD/YY                   MM/DD/YY
.      .
.      @@end
.
/* END OF SAMPLE OUTPUT FOR CIM FILE */                                       */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

      {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE recimrp_p_1 "CIM File"
/* MaxLen: Comment: */

&SCOPED-DEFINE recimrp_p_2 "Product!Line"
/* MaxLen: Comment: */

&SCOPED-DEFINE recimrp_p_3 "Production!Line"
/* MaxLen: Comment: */

&SCOPED-DEFINE recimrp_p_4 "Product Line"
/* MaxLen: Comment: */

&SCOPED-DEFINE recimrp_p_5 "Description"
/* MaxLen: Comment: */

&SCOPED-DEFINE recimrp_p_6 "Start Effective"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

      define variable line  like pt_prod_line no-undo label {&recimrp_p_4}.
      define variable line1 like pt_prod_line no-undo.
      define variable part  like pt_part no-undo.
      define variable part1 like pt_part no-undo.
      define variable prline  like wo_line no-undo.
      define variable prline1 like wo_line no-undo.
      define variable site  like wo_site no-undo.
      define variable start as date label {&recimrp_p_6}
              initial today no-undo.
      define variable ptstatus as character no-undo.
      define variable routing like wo_routing no-undo.
      define variable bom_code like wo_bom_code no-undo.
      define variable fname as character format "x(12)"
              label {&recimrp_p_1} no-undo.
      define variable check_lnd_det as logical.
      define stream cim.

      
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
         
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
line          colon 18
         line1         colon 49
                    label {t001.i}
         part          colon 18
         part1         colon 49
                    label {t001.i}
                    skip (1)
         site          colon 30
         prline        colon 30 ln_desc no-label
         start         colon 30
                    skip (1)
         fname         colon 30
      with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



      /* SET EXTERNAL LABELS */
      setFrameLabels(frame a:handle).

      site = global_site.
      fname = "re" + substring(string(year(today),"9999"),3,2)
               + string(month(today),"99")
               + string(day(today),"99") + ".cim".

/*K1GZ*/ {wbrp01.i}

         repeat on error undo, retry with frame a:

         if line1 = hi_char then line1 = "".
         if part1 = hi_char then part1 = "".

/*K1GZ*/    if c-application-mode <> 'web' then
            update line line1 part part1 site prline start fname with frame a.

/*K1GZ*/ {wbrp06.i &command = update &fields = "  line line1 part part1 site
          prline start fname" &frm = "a"}

/*K1GZ*/ if (c-application-mode <> 'web') or
/*K1GZ*/ (c-application-mode = 'web' and
/*K1GZ*/ (c-web-request begins 'data')) then do:

         /* VALIDATE SITE */
         find si_mstr no-lock where si_site = site no-error.
         if not available si_mstr then do:
        {mfmsg.i 708 3} /* SITE DOES NOT EXIST */
/*K1GZ*/      if c-application-mode = 'web' then return.
/*K1GZ*/      else next-prompt site.
        undo, retry.
         end.
         else if si_db <> global_db then do:
        {mfmsg.i 5421 3} /* SITE IS NOT ASSIGNED TO THIS DATABASE */
/*K1GZ*/      if c-application-mode = 'web' then return.
/*K1GZ*/      else next-prompt site.
        undo, retry.
         end.
         assign global_site = site.
         /* VERIFY PRODUCTION LINE */
         find first ln_mstr no-lock where ln_site = site no-error.
         if available ln_mstr or prline <> "" then do:
        check_lnd_det = yes.
        find ln_mstr no-lock where ln_line = prline
        and ln_site = site no-error.
        if not available ln_mstr then do:
           {mfmsg.i 8526 3}
/*K1GZ*/         if c-application-mode = 'web' then return.
/*K1GZ*/         else next-prompt prline.
           undo,retry.
        end.
        else display ln_desc.
         end.
         else do:
        check_lnd_det = no.
        display "" @ ln_desc.
         end.

         /* CREATE BATCH INPUT STRING */
         bcdparm = "".
         {mfquoter.i line   }
         {mfquoter.i line1  }
         {mfquoter.i part   }
         {mfquoter.i part1  }
         {mfquoter.i site   }
         {mfquoter.i prline }
         {mfquoter.i start  }
         {mfquoter.i fname  }

/*K1GZ*/ end.

            {mfselbpr.i "printer" 132}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

         {mfphead.i}

         output stream cim to value(fname).
         if line1 = "" then line1 = hi_char.
         if part1 = "" then part1 = hi_char.

         /* DEPENDING ON WHAT SELECTION CRITERIA IS ENTERED, AN INDEX     */
         /* SUCH AS pt_prod_part CAN BE EXPLICITLY STATED IN THIS         */
         /* FOR EACH STATEMENT - AS WRITTEN, PROGRESS USES INDEX pt_part  */
         for each pt_mstr no-lock where
         pt_prod_line >= line and pt_prod_line <= line1 and
         pt_part >= part and pt_part <= part1
         with frame b:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame b:handle).

        /* IF ANY PRODUCTION LINES ARE DEFINED FOR THE SITE OR */
        /* PRODUCTION LINE ENTERED*/
        if check_lnd_det then do:
           find first lnd_det no-lock where lnd_line = prline
           and lnd_site = site
           and lnd_part = pt_part
           no-error.
           /* SKIP ITEM IF NOT DEFINED FOR THIS PRODUCTION LINE */
           if not available lnd_det then next.
        end.
        /* VALIDATE ITEM STATUS */
        ptstatus = pt_status.
        substring(ptstatus,9,1) = "#".
        if can-find(isd_det where isd_status = ptstatus
        and isd_tr_type = "ADD-WO") then next.
        /* GET DEFAULT ROUTING & BOM CODE */
        find ptp_det no-lock where ptp_part = pt_part and
        ptp_site = site no-error.
        if available ptp_det then assign
           routing = ptp_routing
           bom_code = ptp_bom_code.
        else assign
           routing = pt_routing
           bom_code = pt_bom_code.
        put stream cim
           "@@batchload recwomt.p" skip
           '""' skip
           '"' site '"' space(1)
           '"' pt_part '"' space(1)
           '"' prline  '"'
           skip
           '"' routing '"' space(1)
           '"' bom_code '"' space(1)
           start
           skip
           '"yes"' skip
           '.' skip
           '.' skip
           "@@end" skip.
        display
           pt_part
           pt_desc1 + " " + pt_desc2 format "x(49)" label {&recimrp_p_5}
           pt_prod_line column-label {&recimrp_p_2}
           prline column-label {&recimrp_p_3}
           routing
           bom_code
        with frame b width 132 STREAM-IO /*GUI*/ .
         end.
         output stream cim close.
         {mfrtrail.i}
      end.

/*K1GZ*/ {wbrp04.i &frame-spec = a}
